class Solution {
public:
    bool isSymmetric(TreeNode* root) 
    {
        return ismirror(root, root);
    }

    bool isMirror(TreeNode* p, TreeNode* q)
    {
        if(p == NULL)
            return true;

        if(p == NULL || q == NULL)
            return false;

        if(p -> val == q -> val)
        {
            return  isMirror(p -> left, q -> right) && isMirror(p -> right, q -> left);
        }

        return false;   
    }
};
